/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.GUI;

import java.awt.Point;
import java.util.Observable;
import java.util.Observer;
import javax.swing.BorderFactory;
import javax.swing.JTextField;
import model.graphic.GraphicModel;
import model.graphic.objects.Graphical;

/**
 *
 * @author Jelle
 */
public class StatusBar extends JTextField implements Observer {
    private String object="";
    private String location="";
    private GraphicModel gmodel;

    public StatusBar(GraphicModel gmodel) {
        this.gmodel=gmodel;
        this.setEditable(false);
        this.setBorder(BorderFactory.createEmptyBorder());
    }

    public void update(Observable o, Object arg) {
        if (arg != null && Graphical.class.isAssignableFrom(arg.getClass())) {
            object = "";
            object+=LabelReader.getInstance().getString("Selected") +": "+arg.getClass().getSimpleName();
            object+=" - "+((Graphical)arg).getName();
            
        } else if(arg != null && Point.class.isAssignableFrom(arg.getClass())) {
            location ="";
            location+=LabelReader.getInstance().getString("Location") +" ( X - Y): ";
            location+=gmodel.getMouseLocation().getX();
            location+=" - ";
            location+=gmodel.getMouseLocation().getY();
            location+=" \t\t";
        }
        setText(" "+location+object);

    }

    /**
     * @param object the object to set
     */
    public void setObject(String object) {
        this.object = object;
    }

    /**
     * @param location the location to set
     */
    public void setLocation(String location) {
        this.location = location;
    }
}
